package com.itheima.web.controller;



import com.itheima.domain.system.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected HttpServletResponse response;

    @Autowired
    protected HttpSession session;

    /*protected String companyId ="1";
    protected String companyName = "传智播客";*/

    protected String getCurrentUserCompanyId(){
        User user = (User) session.getAttribute("user");
        if(user != null){
            return user.getCompanyId();
        }
        return "";
    }

    protected String getCurrenUserCompanyName(){
        User user = (User) session.getAttribute("user");
        if(user != null){
            return user.getCompanyName();
        }
        return "";
    }

































    //protected User user;


    /*@ModelAttribute
    public void setReqAndResp(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        this.request = request;
        this.response = response;
        this.session = session;
        //模拟数据
	    *//*user = (User)session.getAttribute("loginUser");
	    if(user != null) {
		    this.companyId = user.getCompanyId();
		    this.companyName=user.getCompanyName();
	    }*//*
    }*/
}
